// Copyright  2004-2008 Backplane Ltd.
//
// This file is part of Ubiquity formsPlayer
//
// Ubiquity formsPlayer is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3 of the License, or (at your
// option) any later version.
//
// Ubiquity formsPlayer is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
// more details.
//
// You should have received a copy of the GNU General Public License
// along with Ubiquity formsPlayer If not, see <http://www.gnu.org/licenses/>.
//	
//
//   Purpose:  Definition of CDefaultUIEventHandlerMap.
//   $Id$



#pragma once

#include <map>

class CXFormsElement;
struct IDOMEvent;

typedef HRESULT(*HandlerFunction)(CXFormsElement*,IDOMEvent *);
typedef std::map<CComBSTR,HandlerFunction> CMapBSTRToFunc;
typedef std::pair<CComBSTR,HandlerFunction> strFuncPair;
//<summary>
//	static class used to find functionpointers for the UI to use
//	to perform default handling of events.
//</summary>
class CDefaultUIEventHandlerMap
{
public:
	//<summary>
	//	Finds a function to handle the default UI behaviour of an event
	//</summary>
	//<param name="sEventName">event name, used as a key for the funtion</param>
	//<param name="ppFunc">pointer to the returned function pointer</param>
	//<returns>
	//	S_OK if a function exists to handle that event. <br />
	//	S_FALSE if sEventName has no entry in the map
	//</returns>
	static HRESULT GetHandlingFunction(const BSTR sEventName,HandlerFunction * ppFunc);
private:
	CDefaultUIEventHandlerMap();
	//<summary>
	//	Fills sm_FuncMap. 
	//</summary>
	static void createHandlerMap();
	//<summary>
	//	Map used to store the pointers to handler functions.
	//</summary>
	static CMapBSTRToFunc sm_FuncMap;
	static HANDLE sm_hFuncMapMutex;
};
